#!/bin/sh
#localPath=`pwd`
myPath="/usr/logs/"
# Checking file name
fileName="profile"
# config path
path=":/usr/im/lib/*"
# profile file contains key
key="CLASSPATH"
# File directory , Enter
cd /etc
if [ -f "$fileName" ]; then
    grep -q $path $fileName && b="true" || b="false"
    if [ $b == "true" ]; then
        if [ ! -x "$myPath" ]; then
            mkdir "$myPath"
        fi
        cd /usr/im/
        java -Xmx1024m -Xms1024m -Xmn512m com.dianziq.im.server.Main $1 > startup.log &
        sleep 5
        ch=`ps aux|grep java|grep 'com.dianziq.im.server.Main'|grep -v grep|awk '{print $2}'`
        if [ -n "$ch" ]; then     
            echo "***************IM is started, check the log is successfully launched****************"
        else
            echo "IM start fail!"
        fi
    else
        echo "ClassPath isn't config , Do setclasspath.sh file. setclasspath.sh in the run directory."
    fi
else
    echo "Java virtual machine is not installed, Please install the java virtual machine. Do setclasspath.sh file. setclasspath.sh in the run directory."
fi
